package com.lanzuo.yxd.scanner.config;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EventPublisherConfig {

    /**
     * 注入当前的 ApplicationContext
     */
    private final ApplicationContext applicationContext;

    public EventPublisherConfig(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    /**
     * 手动暴露 ApplicationEventPublisher 类型的 Bean
     */
    @Bean
    public ApplicationEventPublisher applicationEventPublisher() {
        return applicationContext;
    }
}